<?php

use backend\assets\PrintAsset;

PrintAsset::register($this);

use backend\modules\statistics\assets\EchartsAsset;
use yii\bootstrap\BootstrapAsset;
BootstrapAsset::register($this);
EchartsAsset::register($this);
$this->title = '仔猪体重分布';

?>


<style>
    .table > tbody > tr > td {
        height: 70px;
        line-height: 70px;
    }
    .row{
        margin-right: 0;
        margin-left: 0;
    }
</style>


<div class="content margin_top_foot">
    <header class="header fixed_top bg_mx_green">
        <div class="back_text" onclick="javascript:history.back(-1)">
            <div class="arrow_left"></div>
            返回
        </div>
        仔猪体重分布
        <div class="header_icon">
            <span class="iconfont icon-home"></span>
        </div>
    </header>
    <div class="row">
        <div class="col-md-10 col-md-offset-1" style="height: 100px;margin-top: 10px">
            <form class="form-inline" style="width: 100%" method="get">
                <div class="form-group" style="width: 80%">
                    <input type="text" name="weight" value="" class="form-control"
                           placeholder="请输入重量分布的数字，如：5,10,15,20,30 数字之间以英文逗号隔开" style="width: 100%;">
                </div>
                <button class="btn btn-success btn-sm" type="submit"> 开始统计</button>

            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-md-8 col-md-offset-1" id="printarea">
            <!--work progress start-->
            <section class="panel">

                <div class="panel-body progress-panel" style="margin-top:-20px;">
                    <div class="task-progress">
                        <h4>仔猪重量分布统计</h4>
                    </div>
                    <div class="task-option">
                    </div>
                </div>
                <table class="table table-hover">
                    <tr>
                        <th>
                            批次
                        </th>
                        <?php foreach ($tabname as $key => $row) { ?>
                            <th>
                                <?= $row ?>
                            </th>
                        <?php } ?>
                        <th>
                            总数
                        </th>
                    </tr>
                    <?php $show = [] ?>

                    <?php foreach ($wiarr as $key => $row) { ?>
                        <tr id="syr<?= $key ?>>" data-key="<?= $key ?>" class="syrc">
                            <td>
                                <?= $key ? $key : '' ?>
                            </td>

                            <?php foreach ($tab as $k => $v) { ?>
                                <td>
                                    <?php
                                    $num = array_key_exists($v, $row) ? count($row[$v]) : 0;
                                    $show[$key][] = ['name' => $tabname[$k], 'value' => $num];
                                    $bi = (array_key_exists($key, $total) ? $total[$key]['total'] : 0) != 0 ? round($num / $total[$key]['total'], 2) * 100 : 0;
                                    echo $num . '|' . $bi . '%';
                                    ?>
                                </td>
                            <?php } ?>
                            <td>
                                <?= array_key_exists($key, $total) ? $total[$key]['total'] : 0 ?>
                            </td>
                        </tr>

                    <?php } ?>

                </table>

            </section>
            <!--work progress end-->
        </div>
    </div>
</div>


<script>
    <?php $this->beginBlock('js_end') ?>



    $(function () {

        function bigtongji() {
            $(this).style({'width': '300px', 'height': '300px;'});
        }
    });
    <?php $this->endBlock('jsend') ?>
    <?php $this->registerJs($this->blocks['js_end'], \yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>

</script>
